#define MENU  1
#define ITEMS 2

static aMenus := {}

//----------------------------------------------------------------------------//

function MenuBegin()

   AAdd( aMenus, { TMenu():New(), {} } )

return ATail( aMenus )[ MENU ]

//----------------------------------------------------------------------------//

function MenuAddItem( cPrompt, cMsg, bAction )

   local mit := TMenuItem():New( cPrompt, cMsg, bAction )

   AAdd( ATail( aMenus )[ ITEMS ], mit )

return mit

//----------------------------------------------------------------------------//

function MenuEnd()

   local oMenu  := ATail( aMenus )[ MENU ]
   local aItems := ATail( aMenus )[ ITEMS ]

   AEval( aItems, { | oItem | oMenu:Add( oItem ) } )

   ASize( aMenus, Len( aMenus ) - 1 )
   if Len( aMenus ) > 0
      ATail( ATail( aMenus )[ ITEMS ] ):bAction = oMenu
   endif

return oMenu

//----------------------------------------------------------------------------//
